package com.wxzhou.wangzhuan.dto.config;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.*;

import java.math.BigDecimal;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class WithdrawConfigDto {

    /**
     * 提现总开关
     */
    @NotNull(message = "提现总开关不能为空")
    private Boolean withdrawEnabled;

    /**
     * 每日允许提多少笔
     */
    @NotNull(message = "每日允许提多少笔不能为空")
    @Min(value = 0, message = "每日允许提多少笔不能小于0")
    private Integer dailyMaxCount;

    /**
     * 配置提现渠道和限制，key表示到账渠道code(paymentType)
     */
    @NotEmpty(message = "金额限制配置不能为空")
    private Map<String, List<WithdrawAmountLimitDto>> amountLimits = new HashMap<>();

    /**
     * 全局配置提现限制
     */
    @NotEmpty(message = "金额限制配置不能为空")
    private List<WithdrawTotalLimitDto> totalLimits = new ArrayList<>();

    /**
     * 配置某支付渠道实名阈值，以及实名描述
     */
    @NotEmpty(message = "配置某支付渠道实名阈值不能为空")
    private Map<String, BigDecimal> withdrawRealNames = new HashMap<>();

    /**
     * 提现间隔时间（秒）
     */
    @NotNull(message = "提现间隔时间不能为空")
    @Min(value = 0, message = "提现间隔时间不能小于0")
    private Integer withdrawInterval;

    /**
     * 可提时间（每日）
     * 格式：HH:mm-HH:mm，例如：09:00-18:00
     */
//    @NotBlank(message = "可提时间不能为空")
//    @Pattern(regexp = "^([01]?[0-9]|2[0-3]):[0-5][0-9]-([01]?[0-9]|2[0-3]):[0-5][0-9]$", message = "可提时间格式不正确，应为HH:mm-HH:mm")
//    private String withdrawTimeRange;

    @NotBlank(message = "可提时间不能为空")
    @Pattern(regexp = "^([01]?[0-9]|2[0-3]):[0-5][0-9]$", message = "可提时间格式不正确，应为HH:mm-HH:mm")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    private LocalTime startTime;

    @NotBlank(message = "结束时间不能为空")
    @Pattern(regexp = "^([01]?[0-9]|2[0-3]):[0-5][0-9]$", message = "可提时间格式不正确，应为HH:mm-HH:mm")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    private LocalTime endTime;

    /**
     * 自动放行开关
     */
    @NotNull(message = "自动放行开关不能为空")
    private Boolean autoApproveEnabled;

    /**
     * 自动放行阈值
     * 大于0生效，提现金额小于等于此值时自动放行
     */
    @NotNull(message = "自动放行阈值不能为空")
    @DecimalMin(value = "0", inclusive = false, message = "自动放行阈值必须大于0")
    private BigDecimal autoApproveThreshold;

    public List<WithdrawTotalLimitDto> getTotalLimits() {
        return totalLimits;
    }

    public void setTotalLimits(List<WithdrawTotalLimitDto> totalLimits) {
        this.totalLimits = totalLimits;
    }

    // Getters and Setters
    public Boolean getWithdrawEnabled() {
        return withdrawEnabled;
    }

    public void setWithdrawEnabled(Boolean withdrawEnabled) {
        this.withdrawEnabled = withdrawEnabled;
    }

    public Integer getDailyMaxCount() {
        return dailyMaxCount;
    }

    public void setDailyMaxCount(Integer dailyMaxCount) {
        this.dailyMaxCount = dailyMaxCount;
    }

    public Map<String, List<WithdrawAmountLimitDto>> getAmountLimits() {
        return amountLimits;
    }

    public void setAmountLimits(Map<String, List<WithdrawAmountLimitDto>> amountLimits) {
        this.amountLimits = amountLimits;
    }

    public Integer getWithdrawInterval() {
        return withdrawInterval;
    }

    public void setWithdrawInterval(Integer withdrawInterval) {
        this.withdrawInterval = withdrawInterval;
    }

    public LocalTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalTime startTime) {
        this.startTime = startTime;
    }

    public LocalTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalTime endTime) {
        this.endTime = endTime;
    }

    public Boolean getAutoApproveEnabled() {
        return autoApproveEnabled;
    }

    public void setAutoApproveEnabled(Boolean autoApproveEnabled) {
        this.autoApproveEnabled = autoApproveEnabled;
    }

    public BigDecimal getAutoApproveThreshold() {
        return autoApproveThreshold;
    }

    public void setAutoApproveThreshold(BigDecimal autoApproveThreshold) {
        this.autoApproveThreshold = autoApproveThreshold;
    }

    public Map<String, BigDecimal> getWithdrawRealNames() {
        return withdrawRealNames;
    }

    public void setWithdrawRealNames(Map<String, BigDecimal> withdrawRealNames) {
        this.withdrawRealNames = withdrawRealNames;
    }
}